package com.shop.advertisement.controller;

import com.shop.advertisement.service.SearchLeftAdService;
import com.shop.pojo.LdbzSearchLeftAd;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/search/left/ad/")
public class SearchLeftAdController {
    private static final Logger logger = LoggerFactory.getLogger(SearchLeftAdController.class);
    @Autowired
    private SearchLeftAdService searchLeftAdService;

    @RequestMapping(value = "/getSearchLeftAdPage", method = RequestMethod.GET)
    public List<LdbzSearchLeftAd> getSearchLeftAdPage(@RequestParam("entity") LdbzSearchLeftAd entity, @RequestParam("start") int start, @RequestParam("limit") int limit) {
        return searchLeftAdService.getSearchLeftAdPage(entity, start, limit);
    }

    @RequestMapping(value = "/countByEntity", method = RequestMethod.GET)
    public long countByEntity(@RequestParam("entity") LdbzSearchLeftAd entity) {
        return searchLeftAdService.countByEntity(entity);
    }

    @RequestMapping(value = "/selectByKey/{id}", method = RequestMethod.GET)
    public LdbzSearchLeftAd selectByKey(@RequestParam("id") Long id) {
        return searchLeftAdService.selectByKey(id);
    }

    @RequestMapping(value = "/deleteByKey/{id}", method = RequestMethod.GET)
    public int deleteByKey(@RequestParam("id") Long id) {
        return searchLeftAdService.deleteByKey(id);
    }

    @RequestMapping(value = "/deleteByKeys/", method = RequestMethod.GET)
    public int deleteByKeys(@RequestParam("ids") List<Long> ids) {
        return searchLeftAdService.deleteByKeys(ids);
    }

    @RequestMapping(value = "/insertByEntity/", method = RequestMethod.GET)
    public int insertByEntity(@RequestParam("entity") LdbzSearchLeftAd entity) {
        return searchLeftAdService.insertByEntity(entity);
    }

    @RequestMapping(value = "/updateByKey/", method = RequestMethod.GET)
    public int updateByKey(@RequestParam("entity") LdbzSearchLeftAd entity) {
        return searchLeftAdService.updateByKey(entity);
    }

    @RequestMapping(value = "/getSearchLeftAdByRedis", method = RequestMethod.GET)
    public List<LdbzSearchLeftAd> getSearchLeftAdByRedis() {
        return searchLeftAdService.getSearchLeftAdByRedis();
    }
}
